//  Copyright (c) 2010 Mahesh Sharma,Matt MacDonald
//
//  Permission is hereby granted, free of charge, to any person obtaining a copy
//  of this software and associated documentation files (the "Software"), to deal
//  in the Software without restriction, including without limitation the rights
//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
//  copies of the Software, and to permit persons to whom the Software is
//  furnished to do so, subject to the following conditions:
//
//  The above copyright notice and this permission notice shall be included in
//  all copies or substantial portions of the Software.
//
//  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
//  THE SOFTWARE.

package org.prx.prp.model;

import java.util.ArrayList;

import org.prx.prp.controller.StreamURLManager;

import android.database.Cursor;

public class Stream {
	public String getDisplayName() {
		return displayName;
	}
	
	public void setSource(Source source) {
		this.source = source;
	}
	public void setDisplayName(String displayName) {
		this.displayName = displayName;
	}
	public String getLogoUrl() {
		return logoUrl;
	}
	public void setLogoUrl(String logoUrl) {
		this.logoUrl = logoUrl;
	}
	public ArrayList<StreamURL> getStreamUrls() {
		return streamUrls;
	}
	public void setStreamUrls(ArrayList<StreamURL> streamUrls) {
		this.streamUrls = streamUrls;
	}
	private Integer  streamId;
	private int  sourceId;
	private String name;
	private String displayName;
	private String frequency;
	private String format;
	private String logoUrl;
	private Source source;
	ArrayList<StreamURL>  streamUrls;
	private String adSlotId; 
	private long  distance;
	public long compareDistance(Stream s)
	{return 0;}
	public long calculateDistance(double latitude,double longitude)/*There is trouble here*/
	{return 0;}
	public Stream(int streamId, int sourceId, String name, String displayName,
			String frequency, String format, String logoUrl, Source source,
			ArrayList<StreamURL> streamUrls, String adSlotId, int distance) {
		super();
		this.streamId = streamId;
		this.sourceId = sourceId;
		this.name = name;
		this.displayName = displayName;
		this.frequency = frequency;
		this.format = format;
		this.logoUrl = logoUrl;
		this.source = source;
		this.streamUrls = streamUrls;
		this.adSlotId = adSlotId;
		this.distance = distance;
	}
	public Stream(Cursor c) {
		this.streamId = c.getInt(c.getColumnIndex("STREAM_ID"));
		this.sourceId =c.getInt(c.getColumnIndex("SOURCE_ID"));
		this.name = c.getString(c.getColumnIndex("STREAM_NAME"));
		this.displayName = c.getString(c.getColumnIndex("STREAM_DISPLAY_NAME"));
		this.frequency = c.getString(c.getColumnIndex("STREAM_FREQUENCY"));
		this.format = c.getString(c.getColumnIndex("STREAM_FORMAT"));
		this.logoUrl =c.getString(c.getColumnIndex("STREAM_LOGO_URL"));
		this.streamUrls=StreamURLManager.findByStreamId(this.streamId);
		this.source = new Source(c);
		this.adSlotId =c.getString(c.getColumnIndex("STREAMS_AD_SLOT_ID"));		
	}
	
	public Integer getStreamId() {
		return this.streamId;		
	}
	public Source getSource() {
		
		return source;
	}
}


